package route

import (
	"go-study-history/tank_war/clinet"
	"net/http"
)

func Init() {
	//默认url
	defaultUrl()
	//坦克操作url
	operate()
}
func defaultUrl() {
	http.HandleFunc("/", index)
}

func operate() {
	http.HandleFunc("operate", defaultOperate)

}

func defaultOperate(writer http.ResponseWriter, request *http.Request) {
	_, _ = writer.Write([]byte(`{"code":0,"msg":"操作默认接口成功"}`))
}

func index(writer http.ResponseWriter, request *http.Request) {
	if clinet.IsNormalRun() {
		_, _ = writer.Write([]byte(`{"code":0,"msg":"websocket服务正在运行"}`))
	} else {
		_, _ = writer.Write([]byte(`{"code":0,"msg":"websocket还未正常运行"}`))
	}

}
